package com.liang.controller;

import com.github.pagehelper.PageInfo;
import com.liang.entity.User;
import com.liang.service.UserService;
import com.liang.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

@ResponseBody
@Controller
public class UserController {

    @Autowired
    UserService userService;

//    @RequestMapping("/student/{id}")
//
//    public User getUserById(@PathVariable("id") Integer id){
//
//        return userService.getUserById(id);
//
//    }

//    @RequestMapping("/login")




//    @RequestMapping("/login")
//    public Result<User> getBooks(User user, HttpSession session){
//
//        Result<User> result = userService.login(user);
//        if (result.isSuccess()){
//            session.setAttribute("loginUser",result.getData());
//        }
//
//        return result;
//    }

    @GetMapping("/student")
    public PageInfo<User> getAllStudentByPage(@RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "5") Integer pageSize){

        return userService.getAllByPage(pageNum, pageSize);


    }



}
